<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.sundy.core.*"%>
<%@page import="com.sundy.tools.InitSystem"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	Context context = Utility.obtainContext(request);
	if (context.isLogin()) {
		response
				.sendRedirect(request.getContextPath() + "/mgr/myspace");
	} else {
%>

<jsp:include flush="true" page="/head.jsp"></jsp:include>
<script type="text/javascript">
<!--
function check() {
	if ($.trim($("#name").val()) == "") {
		alert("请输入用户名");
		return false;
	}
	if ($.trim($("#password").val()) == "") {
		alert("请输入密码");
		return false;
	}
	return true;
}

function frmsubmit() {
	if (check()) {
		$("#frm").submit();
	}
}

$(function() {
	$("#name").keydown(function(event) {
		if (event.keyCode == 13){
		    if ($.trim($("#name").val()) == "") {
		      alert("用户名不能为空！");
		      return;
		    }
			$("#password").focus();
		}
	});
	$("#password").keydown(function(event) {
		if (event.keyCode == 13) {
		    if ($("#password").val() == "") {
		      alert("密码不能为空！");
		      return;
		    }
		 	frmsubmit();
		}
	});
});
-->
</script>

<div id="main" class="center">
	<form action="<%=path%>/login" id="frm" method="post">
		<table
			style="border: 1px solid rgb(133, 138, 145); width: 100%; margin-top: 100px;">
			<tr>
				<td colspan="2" class="center"
					style="background-color: rgb(133, 138, 145); color: #ffffff; font-weight: bold;">
					登录系统
				</td>
			</tr>
			<tr>
				<td colspan="2" class="center">
					<%
						if (InitSystem.needCreateAdmin()) {
					%>
					<span style="color: red">系统没有用户，您这里输入需要的用户名和密码，然后点击Login按钮，将会自动创建一个管理员用户</span>
					<input type="hidden" name="newAdmin" value="1" />
					<%
						} else {
					%>
					请输入您的帐号和密码<%
						}
					%>
				</td>
			</tr>
			<tr>
				<td width="30%" class="right">
					用户名
				</td>
				<td class="left">
					&nbsp;
					<input class="userinfo" type="text" size="16" name="name" id="name" />
				</td>
			</tr>
			<tr>
				<td width="30%" class="right">
					密&nbsp;码
				</td>
				<td class="left">
					&nbsp;
					<input class="userinfo" type="password" size="16" name="password"
						id="password" />
				</td>
			</tr>
			<tr>
				<td colspan="2" align="middle">
					<input type="button" name="Login" value="Login"
						onclick="frmsubmit();" />
				</td>
			</tr>
		</table>
	</form>
</div>
<jsp:include page="footer.jsp"></jsp:include>
<%
	}
%>
